package com.ly.aps.system.provider.controller;

import com.ly.aps.system.model.dto.ModeDTO;
import com.ly.aps.system.model.dto.ItemDTO;
import com.ly.aps.system.provider.service.ItemService;
import com.ly.aps.system.provider.model.Item;
import com.stone.commons.core.model.ApiResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
import java.util.HashMap;

@Slf4j
@RestController
@RequestMapping("/item")
@Api(tags = "Item信息查询")
@CrossOrigin
public class ItemInfoController {

    @Autowired
    private ItemService itemService;

    @ApiOperation(value = "Item信息查询")
    @RequestMapping(value = "/getAllItemList", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "status", value = "状态", required = false),
            @ApiImplicitParam(name = "type", value = "类型", required = false),
            @ApiImplicitParam(name = "creator", value = "创建人", required = false),
            @ApiImplicitParam(name = "itemId", value = "item编码", required = false),
            @ApiImplicitParam(name = "createTime", value = "创建时间", required = false)
    })
    public ApiResult<String> getAllItemList(@RequestParam(value = "status", required = false) Integer status,
                                                     @RequestParam(value = "type", required = false) Integer type,
                                                     @RequestParam(value = "creator", required = false) String creator,
                                                     @RequestParam(value = "itemId", required = false) String itemId,
                                                     @RequestParam(value = "createTime", required = false) String createTime){
       return ApiResult.success(itemService.getAllItemList(status, type, creator, itemId, createTime));
    }
    
    @ApiOperation(value = "Item信息查询")
    @RequestMapping(value = "/getItemList", method = RequestMethod.GET)
    @ApiImplicitParams({
    		@ApiImplicitParam(name = "page", value = "页码", required = true),
    		@ApiImplicitParam(name = "count", value = "每页个数", required = true),
            @ApiImplicitParam(name = "status", value = "状态", required = false),
            @ApiImplicitParam(name = "type", value = "类型", required = false),
            @ApiImplicitParam(name = "creator", value = "创建人", required = false),
            @ApiImplicitParam(name = "itemId", value = "item编码", required = false),
            @ApiImplicitParam(name = "createTime", value = "创建时间", required = false)
    })
    public ApiResult<String> getItemList(@RequestParam(value = "page", required = true) Integer page,
    												@RequestParam(value = "count", required = true) Integer count,
    												@RequestParam(value = "status", required = false) Integer status,
                                                     @RequestParam(value = "type", required = false) Integer type,
                                                     @RequestParam(value = "creator", required = false) String creator,
                                                     @RequestParam(value = "itemId", required = false) String itemId,
                                                     @RequestParam(value = "createTime", required = false) String createTime){
               
        return ApiResult.success(itemService.getItemList(page, count, status, type, creator, itemId, createTime));
    }
   
}
